#include <stdio.h>
#include <string.h>

typedef struct date {
    int year;
    int month;
    int day;
} DATE;
typedef struct student {
    long studentID;
    char stuName[10];
    char stuSex;
    DATE birthday;
    int mathScore;
} Student;

int main() {
    //可以使用{}初始化
    Student stu1 = {2019000001, "张三", 'M', {1999, 9, 9}, 100};
    printf("studentID=%ld, stuName=%s, stuSex=%c, birthday=%d-%d-%d, mathScore=%d\n", stu1.studentID, stu1.stuName,
           stu1.stuSex, stu1.birthday.year, stu1.birthday.month, stu1.birthday.day, stu1.mathScore);

    Student stu2;
    //不允许使用{}整体赋值
    //    stu2= {2019000002, "李四", 'F', {1998, 8, 8}, 90};
    //字符数组赋值时需要使用strcpy()
    //stu2.stuName = "李四"; //错误
    strcpy(stu2.stuName, "李四");
    stu2.studentID = 2019000002;
    stu2.stuSex = 'F';
    stu2.birthday.year = 1998;
    stu2.birthday.month = 8;
    stu2.birthday.day = 8;
    stu2.mathScore = 90;
    printf("studentID=%ld, stuName=%s, stuSex=%c, birthday=%d-%d-%d, mathScore=%d\n", stu2.studentID, stu2.stuName,
           stu2.stuSex, stu2.birthday.year, stu2.birthday.month, stu2.birthday.day,
           stu2.mathScore);

}